/**
 * 智能文档管理系统类型定义
 */

// 文档分类类型
export interface DocumentCategory {
  id: string;
  name: string;
  icon?: string;
  color?: string;
  description?: string;
  parent_id: string | null;
  is_system?: boolean;
  sort_order?: number;
  children?: DocumentCategory[];
  document_count?: number;
  created_at: string;
  updated_at?: string;
}

// 文档标签类型
export interface DocumentTag {
  id: string;
  name: string;
  description?: string;
  color?: string;
  document_count?: number;
  created_at?: string;
  updated_at?: string;
}

// 个人文档类型
export interface PersonalDocument {
  id: string;
  title: string;
  description?: string;
  filename: string;
  file_path: string;
  file_size: number;
  file_type: string;
  mime_type: string;
  category_id?: string;
  category?: {
    id: string;
    name: string;
    icon?: string;
  };
  tags: DocumentTag[];
  is_favorite: boolean;
  is_pinned: boolean;
  view_count: number;
  created_at: string;
  updated_at: string;
  last_accessed_at?: string;
}

// 文档列表查询参数
export interface DocumentListParams {
  page?: number;
  size?: number;
  category_id?: string;
  search?: string;
  tags?: string[];
  is_favorite?: boolean;
  is_pinned?: boolean;
  sort_by?: 'created_at' | 'updated_at' | 'title' | 'file_size' | 'view_count';
  sort_order?: 'asc' | 'desc';
}

// 文档列表响应
export interface DocumentListResponse {
  items: PersonalDocument[];
  total: number;
  page: number;
  size: number;
  total_pages: number;
}

// 文档与检查项关联类型
export interface DocumentComplianceRelation {
  id: string;
  document_id: string;
  compliance_template_item_id: string;
  relation_type: 'evidence' | 'reference' | 'template';
  description?: string;
  created_at: string;
  compliance_item?: {
    id: string;
    title: string;
  };
  document?: {
    id: string;
    title: string;
    filename: string;
  };
}

// 文件类型信息
export interface FileTypeInfo {
  icon: string;
  color: string;
  name: string;
}

// 文档统计信息
export interface DocumentStatistics {
  total_documents: number;
  total_favorites: number;
  total_pinned: number;
  by_category: Record<string, number>;
  by_type: Record<string, number>;
  total_size: number;
  total_size_formatted: string;
  recent_uploads: number;
}

// 分类统计信息
export interface CategoryStatistics {
  total_categories: number;
  system_categories: number;
  custom_categories: number;
}

// 视图模式
export type ViewMode = 'list' | 'card';

// 排序字段
export type SortField = 'created_at' | 'updated_at' | 'title' | 'file_size' | 'view_count';

// 排序方向
export type SortOrder = 'asc' | 'desc';

// 关联类型
export type RelationType = 'evidence' | 'reference' | 'template';
